import redis

try:
    myredis = redis.StrictRedis(host='localhost', port=6379)
except Exception as e:
    print(e.message)

myredis.set('name','xiaoming')
myvalue = myredis.get('name')       # 返回的是字节流
mystr = myvalue.decode('utf-8')
print(mystr)